# Maintainer: Orhun Parmaksız <orhunparmaksiz@gmail.com>
pkgname=cargo-shuttle
pkgver=0.35.2
pkgrel=0
pkgdesc="Cargo command for the Shuttle platform"
url="https://github.com/shuttle-hq/shuttle"
license="Apache-2.0"
# s390x, ppc64le, riscv64: blocked by ring crate
arch="all !s390x !ppc64le !riscv64"
makedepends="cargo cargo-auditable"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="https://github.com/shuttle-hq/shuttle/archive/v$pkgver/shuttle-$pkgver.tar.gz"
builddir="$srcdir/shuttle-$pkgver"
# tests require git/submodules to be initialized
options="!check"

prepare() {
	default_prepare
	cargo fetch --locked
}

build() {
	cargo auditable build -p "$pkgname" --release --frozen
	mkdir -p completions/
	local compgen="target/release/$pkgname generate shell"
	$compgen bash >"completions/$pkgname.bash"
	$compgen fish >"completions/$pkgname.fish"
	$compgen zsh >"completions/_$pkgname"
	mkdir -p man/
	"target/release/$pkgname" generate manpage > "man/$pkgname.1"
}

package() {
	install -Dm755 "target/release/$pkgname" -t "$pkgdir/usr/bin/"
	install -Dm644 README.md -t "$pkgdir/usr/share/doc/$pkgname"
	install -Dm644 "completions/$pkgname.bash" "$pkgdir/usr/share/bash-completion/completions/$pkgname"
	install -Dm644 "completions/$pkgname.fish" -t "$pkgdir/usr/share/fish/vendor_completions.d"
	install -Dm644 "completions/_$pkgname" -t "$pkgdir/usr/share/zsh/site-functions"
	install -Dm 644 "man/$pkgname.1" -t "$pkgdir/usr/share/man/man1"
}

sha512sums="
cea200eac3ace4b82ebf1daa7034136a2ba296c1a3a3579cbee9be613fead593fe38a2c35f673a308ac6cd72d43024cb874d1fa99fe05f982ae2eac945e6a6be  shuttle-0.35.2.tar.gz
"
